<script type="text/javascript">
    $(document).ready(function() {
        $('#grid').dataTable({
            "bJQueryUI": false,
            "bAutoWidth": false,
            "sPaginationType": "full_numbers",
            "sDom": '<"H"fl>t<"F"ip>',
            "aaSorting": [[4, "desc"]]
        });
    });
</script>
<div class="widget">
    <div class="whead"><h6>
    LISTADO DE VENTAS
    </h6><div class="clear"></div></div>
    
    <div class="shownpars">
    
    <div >
    <table cellpadding="0" cellspacing="0" border="0" id="grid">
            <thead>
                    <tr>
                        <th>Codigo</th>
                        <th>Sucursal</th>
                        <th>Cliente</th>
                        <th>Precio Total</th>
                        <th>Fecha</th>
                        <th>Accion</th>
                    </tr>
                </thead>
            <tbody>
                    <?php  $i = 0; $total = 0.00; ?>
                <?php if(!empty($ventas)):?>    
                <?php foreach ($ventas as $ven):$i++;  ?>
                
                <tr>
                    <td><?php echo $ven['Ventasproducto']['codigoventa']; ?></td>
                    <td><?php echo $ven['Sucursale']['nombre']; ?></td>
                    <td><?php echo $ven['Cliente']['nombre']; ?></td>
                    <td><?php echo $ven['Ventasproducto']['preciototal']; ?></td>
                    <td><?php echo $ven['Ventasproducto']['created']; ?></td>
                    <td>
                    <?php echo $this->Html->link('Nota de Impresion',array('action' => 'notaventa',$ven['Ventasproducto']['id']),array('class' => 'buttonS bGreyish'));?>
                    <?php echo $this->Html->link('Venta',array('action' => 'index',$ven['Ventasproducto']['cliente_id'],$ven['Ventasproducto']['id']),array('class' => 'buttonS bGold'));?>
                    <?php if($ven['Ventasproducto']['prestado'] == 1):?>
                    <b  class="buttonS bGreen">PRESTADO</b>
                    <?php endif;?>
                    <?php echo $this->Html->link('Eliminar',array('action' => 'cancelaventa',$ven['Ventasproducto']['id']),array('class' => 'buttonS bRed'));?>
                    </td>
                    
                </tr>
                
            <?php endforeach; ?>
            <?php endif;?>
                </tbody>
        </table>
        
    </div>
        
    </div> 
</div>

<?php echo $this->Js->writeBuffer(); ?>